<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ElectricAlarmRecord extends Model
{
    public $timestamps = false;
    protected $connection = 'mysql_center';
    protected $table = 'electric_alarm_record';

    public function user()
    {
        //electric_platform_owner
        return $this->hasOne(ElectricPlatformOwner::class, 'id', 'user_id');
    }

    public function getAlarmTypeAttribute($value)
    {

        $text = '';
        //报警类型：1，设备故障；2，催费报警；3,采集异常 4：整天未上报数据；5,15分钟采集异常，6，8小时上报检测
        switch ($value) {
            case 1:
                $text = '设备故障';
                break;
            case 2:
                $text = '催费报警';
                break;
            case 3:
                $text = '采集异常';
                break;
            case 4:
                $text = '整天未上报数据';
                break;
            case 5:
                $text = '15分钟采集异常';
                break;
            case 6:
                $text = '阀控异常';
                break;
            case 7:
                $text = '8小时内上报数据异常';
        }

        return $text;
    }
}
